package services

import (
	"context"
	"wxapi/internal/svc"
	"wxapi/models"
)

func GetAdvListByPosition(ctx context.Context, svcCtx *svc.ServiceContext, pos int64, page, pageSize int64) ([]*models.Adv, error) {
	advList := make([]*models.Adv, 0)

	svcCtx.Mysql.Model(&models.Adv{}).Where("position_id = ? AND state = 100 AND now() BETWEEN adv_begin_time AND adv_end_time", pos).Offset(int(page * pageSize)).Limit(int(pageSize)).Order("`order`").Find(&advList)

	return advList, nil
}
